"""
    This file is used to generate functor.gen.hpp

    @author: Wolfhead
"""

from codeParser import CodeParser

if __name__ == "__main__" :
    parser = CodeParser()
    code = parser.read("../acapella/delegate/functor_gen_base.hpp")

    count = 10

    gen_target = open("../acapella/delegate/functor_gen.hpp", "w+", 0)

    replace = {
        "FUNCTOR_TEMPLATE_ARGS" : "",
        "FUNCTOR_FUNCTION_ARGS" : "",
        "FUNCTOR_FUNCTION_PARA" : "",
        }


    i = 0;
    while (i <= count) :
        if i == 0:
            pass;
        elif i == 1:
            replace["FUNCTOR_TEMPLATE_ARGS"] = ", typename T0"
            replace["FUNCTOR_FUNCTION_ARGS"] = "T0 t0"
            replace["FUNCTOR_FUNCTION_PARA"] = "t0"
        else:
            replace["FUNCTOR_TEMPLATE_ARGS"] += ", typename T%d" % (i - 1,)
            replace["FUNCTOR_FUNCTION_ARGS"] += ", T%d t%d" % (i - 1, i - 1)
            replace["FUNCTOR_FUNCTION_PARA"] += ", t%d" % (i - 1,)

        gen_target.write(parser.parse(code,replace))

        i += 1

    gen_target.close()
    print("finished")
            
    
